package cn.codergege.myspider.component;

import cn.codergege.myspider.utils.MyspiderUtils;

import java.util.ArrayList;
import java.util.List;

// TODO: 2019-05-30 @Getter @Setter 
public class Result<T> {
    private List<Request> requests = new ArrayList<>(); // 解析出的新的请求
    private T item; // 解析出的 item

    public Result() {}

    public Result(T item) {
        this.item = item;
    }

    // TODO: 这里需要返回 Result 吗？
    public void addRequest(Request request) {
        this.requests.add(request);
    }

    public void addRequests(List<Request> requests) {
        if(!MyspiderUtils.isEmpty(requests)) {
            this.requests.addAll(requests);
        }
    }

    public List<Request> getRequests() {
        return requests;
    }

    public void setRequests(List<Request> requests) {
        this.requests = requests;
    }

    public T getItem() {
        return item;
    }

    public void setItem(T item) {
        this.item = item;
    }
}
